amba_pl011: Round input clock up
authorPhil Elwell <phil@raspberrypi.org>
Wed, 1 Mar 2017 16:07:39 +0000 (16:07 +0000)
committerRaspbian kernel package updater <root@raspbian.org>
Thu, 15 Feb 2018 17:28:59 +0000 (17:28 +0000)
commit5eac6aed30869b3bbb4a6f19e6c9400a1a66eb1b
tree7055c94c90265f263d0cb9f7f3411ec99ffae740
parent74f8af2792748661f75a32c7c5723b8632081e60
amba_pl011: Round input clock up

The UART clock is initialised to be as close to the requested
frequency as possible without exceeding it. Now that there is a
clock manager that returns the actual frequencies, an expected
48MHz clock is reported as 47999625. If the requested baudrate
== requested clock/16, there is no headroom and the slight
reduction in actual clock rate results in failure.

Detect cases where it looks like a "round" clock was chosen and
adjust the reported clock to match that "round" value. As the
code comment says:

/*
 * If increasing a clock by less than 0.1% changes it
 * from ..999.. to ..000.., round up.
 */

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
drivers/tty/serial/amba-pl011.c